/**
 * Copyright 2015-2016 eyaomall.cn
 * All rights reserved.
 *
 * @project
 * @author jackey
 * @version 1.0
 * @date 2016-01-06
 */
package com.eyaomall.wxmall.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.eyaomall.wxmall.model.po.Goods;
import com.eyaomall.wxmall.model.vo.GoodsVO;
import com.lycheeframework.core.annotation.NameSpace;
import com.lycheeframework.core.cmp.kit.PageHTTPObject;
import com.lycheeframework.core.cmp.kit.Pages;
import com.lycheeframework.core.support.DaoSupport;

/**
 * GoodsDao
 * 
 * @author pro
 */
@Repository
@NameSpace("goods")
public class GoodsDao extends DaoSupport<Goods> {

	/**
	 * 根据ID查询产品信息
	 * 
	 * @param id
	 * @return
	 */
	public Goods queryById(Integer id) {
		Goods goods = new Goods();
		goods.setId(id);

		return (Goods) super.query(goods);
	}

	/**
	 * 根据ID查询产品信息
	 * 
	 * @param id
	 * @return
	 */
	public Goods query(Integer id) {
		Goods goods = new Goods();
		goods.setId(id);

		return (Goods) super.query("queryById", goods);
	}

	/**
	 * 根据ids查询产品列表信息
	 * 
	 * @param ids
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Goods> list(String ids) {
		Map<String, String> data = new HashMap<String, String>();
		data.put("ids", ids);

		return super.list(data);
	}

	/**
	 * 根据ids查询我的产品信息
	 * 
	 * @param ids
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Goods> hotGoods(Goods goods) {

		return super.list("hotGoods", goods);
	}

	/**
	 * 分页显示产品列表
	 */
	public Pages<?> page(GoodsVO goodsVO, PageHTTPObject object) {

		return page("page", goodsVO, object);
	}

	/**
	 * 更新库存
	 * 
	 * @param goods
	 * @return
	 */
	public boolean updateInventory(Goods goods) {

		return super.update("updateInventory", goods) > 0 ? true : false;
	}

	/**
	 * 热卖商品列表
	 * 
	 * @param goods
	 * @param httpObject
	 * @return
	 */
	public Pages<?> hotGoods(Goods goos, PageHTTPObject httpObject) {
		return super.page("hot_page", goos, httpObject);
	}
}
